import co from 'co';

export const request = (path, data) => {
  let options = {
    method: 'post',
    body: data,
  };

  return co(function* () {
    let res = yield fetch(path, options);
    if (res.status > 400) {
      throw res;
    }

    res = yield  res.json();
    if (res.code == '10000') {
      return res.data;
    }
    throw res;
  });
};
